package com.zhixiang.xaec.action.safebase.relatedparty;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.google.gson.Gson;
import com.zhixiang.core.command.QueryFilter;
import com.zhixiang.core.entity.TreeObj;
import com.zhixiang.core.util.YearGridCrud;
import com.zhixiang.core.web.action.BaseAction;
import com.zhixiang.xaec.entity.safebase.relatedparty.ExistingProblems;
import com.zhixiang.xaec.service.safebase.relatedparty.ExistingProblemsService;

@Controller
public class ExistingProblemsAction extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4836259487960382781L;
	private ExistingProblems existingProblems;
	
	@Autowired
	private ExistingProblemsService existingProblemsService;
	
	public void setExistingProblems(ExistingProblems existingProblems){
		this.existingProblems=existingProblems;
	}
	
	public ExistingProblems getExistingProblems(){
		return existingProblems;
	}
	
	public String list(){
	
		QueryFilter localQueryFilter = new QueryFilter(getRequest());
        List<ExistingProblems> localList = this.existingProblemsService.getAll(localQueryFilter);
        setSuccess(true);
        setTotalCounts(localQueryFilter.getPagingBean().getTotalItems());
        // 返回结果集
        setResult(localList);
        return SUCCESS;
	}
	
	public String delete(){
	
		try {
			String[] ids=getRequest().getParameterValues("ids");
			existingProblemsService.delete(ids);
		} catch (Exception e) {
			setMsg("删除失败！");
		}
		return SUCCESS;
	}
	
	public String save(){
		try {
			existingProblemsService.save(existingProblems);
		} catch (Exception e) {
			setMsg("保存失败！");
		}
		return SUCCESS;
	}
	
	public String get(){
	
		String id=getRequest().getParameter("id");
		if(!"".equals(id)&& id != null){
			setResult(existingProblemsService.get(Long.valueOf(id)));
		}
		return SUCCESS;
	}
	
}
